# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

pkgbase=gmp
pkgname=('gmp' 'gmp-devel')
pkgver=6.1.0
pkgrel=1
pkgdesc="A free library for arbitrary precision arithmetic"
groups=('libraries')
arch=('i686' 'x86_64')
url="http://gmplib.org/"
license=('LGPL3')
install=gmp.install
source=(ftp://ftp.gmplib.org/pub/gmp-${pkgver}/gmp-${pkgver}.tar.xz{,.sig}
        gmp-5.1.2-msys2.patch)
md5sums=('a9868ef2556ad6a2909babcd1428f3c7'
         'SKIP'
         '50e7a6017b601f073da044f5a5b36905')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/gmp-5.1.2-msys2.patch

  autoreconf -fi
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --build=${CHOST} \
    --prefix=/usr \
    --enable-cxx \
    --enable-fat \
    --enable-shared --disable-static
  make
  make DESTDIR="${srcdir}/dest" install
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check
}

package_gmp() {
  mkdir -p ${pkgdir}/usr
  cp -rf $srcdir/dest/usr/bin ${pkgdir}/usr/
  cp -rf $srcdir/dest/usr/share ${pkgdir}/usr/
}

package_gmp-devel() {
  groups=('development')
  options=(staticlibs)
  depends=("gmp=${pkgver}")
  pkgdesc="GMP headers and libraries"

  mkdir -p ${pkgdir}/usr
  cp -rf $srcdir/dest/usr/include ${pkgdir}/usr/
  cp -rf $srcdir/dest/usr/lib ${pkgdir}/usr/
}
